Skip to main content

Main toolbar customization

The main toolbar supports full customization to allow flexible integration in your application.

You can:

  • Configure the toolbar with only the buttons you need, and in the order you want them to appear.

  • Use default buttons or integrate custom ones.

  • Provide a custom button implementation, including its icon, checked state, and click behavior.

  • Use default button callbacks in your custom UI

The following default buttons are available:

MainToolbarButtonType.InstrumentSearch()
MainToolbarButtonType.Aggregation()
MainToolbarButtonType.Studies()
MainToolbarButtonType.Drawings()
MainToolbarButtonType.Settings()

You can include any subset of these in any order to build your toolbar.

Adding a Custom Button

To include your own button in the toolbar, use the Custom implementation of MainToolbarButtonType:

MainToolbarButtonType.Custom(
name = "MyCustomButton",
icon = Icons.Default.YourIcon,
isEnabled = true,
onClick = { /* your logic */ },
checked = false
)

Toolbar Configuration Example

val mainToolbarConfig = listOf(
MainToolbarButtonType.InstrumentSearch(),
MainToolbarButtonType.Aggregation(),
MainToolbarButtonType.Custom(
name = "MyCustomButton",
icon = Icons.Default.Star,
isEnabled = true,
onClick = { /* handle click */ },
checked = false
)
)

Pass this configuration to DxChartsScreen.

DxChartsScreen(
//...
mainToolbarConfig = mainToolbarConfig
)

Building a Custom Toolbar

You can fully implement your own UI and manually bind button logic. You should create MainToolbarSelectorController and provide callbacks to the view:

val mainToolbarSelectorController = MainToolbarSelectorFactory.create(this)
// Example usages
IconButton(onClick = { mainToolbarSelectorController.openInstrumentList() }) { ... }
IconButton(onClick = { mainToolbarSelectorController.openAggregations(true) }) { ... }
IconButton(onClick = { mainToolbarSelectorController.openStudies(true) }) { ... }
IconButton(onClick = { mainToolbarSelectorController.openDrawings() }) { ... }
IconButton(onClick = { mainToolbarSelectorController.openSettings() }) { ... }